package 数组和链表;

import 抽象数据类型.ListNode;

/**
 * @author: yangwk
 * @date: 2023/4/4
 * @description:
 **/
public class 构造链表 {
    public static ListNode buildListNode(int[] arr) {
        ListNode head = null;
        ListNode temp = null;
        for (int i : arr) {
            if (head == null) {
                head = new ListNode(i);
                temp = head;
            }else{
                temp.next = new ListNode(i);
                temp = temp.next;
            }
        }
        return head;
    }
}
